package com.etv.launcher.ui.component.status;

import android.content.Context;
import android.view.View;
import android.view.ViewGroup;

import androidx.constraintlayout.widget.Constraints;

public abstract class BaseStatusBarComponent extends View implements StatusBarComponent {
    protected View rootView;
    protected boolean isSelected = false;

    public BaseStatusBarComponent(Context context) {
        super(context);
        this.setLayoutParams(new ViewGroup.LayoutParams(20,20));
    }

    @Override
    public void setHeight(int heightPx) {
        ViewGroup.LayoutParams params = rootView.getLayoutParams();
        if (params == null) {
            params = new ViewGroup.LayoutParams(
                    ViewGroup.LayoutParams.WRAP_CONTENT,
                    heightPx
            );
        } else {
            params.height = heightPx;
        }
        rootView.setLayoutParams(params);
    }

    @Override
    public View getRootView() {
        return rootView;
    }

    @Override
    public void setSelected(boolean selected) {
        isSelected = selected;
        updateSelectionUI(selected);
    }

    @Override
    public boolean isSelected() {
        return isSelected;
    }

    protected abstract void updateSelectionUI(boolean selected);
}
